<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/4/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/25/wxpython%E7%BB%98%E5%88%B6%E7%9B%B4%E7%BA%BF/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/25/wxpython%E7%BB%98%E5%88%B6%E7%9B%B4%E7%BA%BF/" class="post-title-link" itemprop="url">wxpython绘制直线</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-25 16:27:51" itemprop="dateCreated datePublished" datetime="2023-12-25T16:27:51+08:00">2023-12-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2023/12/25/wxpython%E7%BB%98%E5%88%B6%E7%9B%B4%E7%BA%BF/" class="post-meta-item leancloud_visitors" data-flag-title="wxpython绘制直线" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/25/wxpython%E7%BB%98%E5%88%B6%E7%9B%B4%E7%BA%BF/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/25/wxpython%E7%BB%98%E5%88%B6%E7%9B%B4%E7%BA%BF/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/seniorwizard/article/details/131143177">https://blog.csdn.net/seniorwizard/article/details/131143177</a></p>
<h3 id="wx-DC及其导出类"><a href="#wx-DC及其导出类" class="headerlink" title="wx.DC及其导出类"></a>wx.DC及其导出类</h3><p>​        要开始绘制图形，必须创建一个设备上下文(DC)对象。在wxPython中，wx.DC定义为可以在其上绘制图形和文本的设备上下文。它旨在表示不同的输出设备，并提供了一个通用的抽象API，用于在其中任何一个设备上绘图。</p>
<p>​        wx.DC是一个抽象基类，不能直接创建。不管是在屏幕上绘图，还是打印输出，都需要选择一个派生类来完成。每个派生类都在特定的条件下使用，wxPython提供了以下wx.DC派生类：<br><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231225162936.png"></p>
<h3 id="绘制一条直线"><a href="#绘制一条直线" class="headerlink" title="绘制一条直线"></a>绘制一条直线</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> wx</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">SampleDrawLine</span>(<span class="params">wx.Frame</span>):</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span>(<span class="params">self, *args, **kw</span>):</span></span><br><span class="line">        <span class="built_in">super</span>(SampleDrawLine, self).__init__(*args, **kw)</span><br><span class="line">        self.InitUi()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">InitUi</span>(<span class="params">self</span>):</span></span><br><span class="line">        self.SetTitle(<span class="string">&quot;test&quot;</span>)</span><br><span class="line">        self.SetSize(<span class="number">400</span>, <span class="number">240</span>)</span><br><span class="line">        wx.CallLater(<span class="number">2000</span>, self.DrawLine)</span><br><span class="line">        self.Centre()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">DrawLine</span>(<span class="params">self</span>):</span></span><br><span class="line">        dc = wx.ClientDC(self)</span><br><span class="line">        dc.DrawLine(<span class="number">50</span>, <span class="number">60</span>, <span class="number">190</span>, <span class="number">60</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span>():</span></span><br><span class="line">    app = wx.App()</span><br><span class="line">    sample = SampleDrawLine(<span class="literal">None</span>)</span><br><span class="line">    sample.Show()</span><br><span class="line">    app.MainLoop()</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    main()</span><br></pre></td></tr></table></figure>
<p>​        运行上面的代码，两秒钟过去后，我们在框架窗口上画一条线。我们在创建窗口之后调用DrawLine()方法。如果在窗口创建时就绘制，我们所有的在客户区的绘制信息将被丢掉。但可以在创建窗口后开始绘图，这就是为什么调用wx.CallLater()方法的原因。</p>
<p>​        创建一个wx.ClientDC设备上下文。唯一的参数是要绘制的窗口。在本例中，它是self，它是对wx.Frame控件的引用。然后调用设备上下文的DrawLine()方法，在窗口上画了一条线。</p>
<p>​        在上面的例子中，当我们调整窗口的大小时，窗口会重画，这时候直线会消失，因此在窗口需要重新绘制的时候，都需要重新绘制这条线。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/13543.gif" style="zoom:67%;">

<p>​        <strong>解决办法是wx.PaintEvent事件，每当窗口被重新绘制时，将触发该事件，我们在该事件绑定的方法中绘制就可以解决直线消失的问题</strong>。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> wx</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">SampleDrawLine</span>(<span class="params">wx.Frame</span>):</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span>(<span class="params">self, *args, **kw</span>):</span></span><br><span class="line">        <span class="built_in">super</span>(SampleDrawLine, self).__init__(*args, **kw)</span><br><span class="line">        self.InitUi()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">InitUi</span>(<span class="params">self</span>):</span></span><br><span class="line">        self.SetTitle(<span class="string">&quot;test&quot;</span>)</span><br><span class="line">        self.SetSize(<span class="number">400</span>, <span class="number">240</span>)</span><br><span class="line">        self.Bind(wx.EVT_PAINT, self.OnPaint)</span><br><span class="line">        self.Centre()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">OnPaint</span>(<span class="params">self, e</span>):</span></span><br><span class="line">        dc = wx.ClientDC(self)</span><br><span class="line">        dc.DrawLine(<span class="number">50</span>, <span class="number">60</span>, <span class="number">190</span>, <span class="number">60</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span>():</span></span><br><span class="line">    app = wx.App()</span><br><span class="line">    sample = SampleDrawLine(<span class="literal">None</span>)</span><br><span class="line">    sample.Show()</span><br><span class="line">    app.MainLoop()</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    main()</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/135423.gif" style="zoom:67%;">

<p>​        我们将OnPaint方法绑定到wx.PaintEvent事件。这意味着每次重新绘制窗口时，我们都会调用OnPaint()方法。现在调整窗口的大小(覆盖它，最大化它)，这条线将不会消失。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/24/wxpython%E4%BD%BF%E7%94%A8opencv%E6%98%BE%E7%A4%BA%E6%91%84%E5%83%8F%E5%A4%B4%E8%A7%86%E9%A2%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/24/wxpython%E4%BD%BF%E7%94%A8opencv%E6%98%BE%E7%A4%BA%E6%91%84%E5%83%8F%E5%A4%B4%E8%A7%86%E9%A2%91/" class="post-title-link" itemprop="url">wxpython使用opencv显示摄像头视频</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-24 21:17:41" itemprop="dateCreated datePublished" datetime="2023-12-24T21:17:41+08:00">2023-12-24</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2023/12/24/wxpython%E4%BD%BF%E7%94%A8opencv%E6%98%BE%E7%A4%BA%E6%91%84%E5%83%8F%E5%A4%B4%E8%A7%86%E9%A2%91/" class="post-meta-item leancloud_visitors" data-flag-title="wxpython使用opencv显示摄像头视频" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/24/wxpython%E4%BD%BF%E7%94%A8opencv%E6%98%BE%E7%A4%BA%E6%91%84%E5%83%8F%E5%A4%B4%E8%A7%86%E9%A2%91/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/24/wxpython%E4%BD%BF%E7%94%A8opencv%E6%98%BE%E7%A4%BA%E6%91%84%E5%83%8F%E5%A4%B4%E8%A7%86%E9%A2%91/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/qsyll0916/p/8973163.html">https://www.cnblogs.com/qsyll0916/p/8973163.html</a></p>
<p>​        直接上代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> cv2</span><br><span class="line"><span class="keyword">from</span> wx <span class="keyword">import</span> *</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">camera</span>(<span class="params">Frame</span>):</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span>(<span class="params">self, parent, title</span>):</span></span><br><span class="line">        Frame.__init__(self, parent, title=title, size=(<span class="number">600</span>, <span class="number">600</span>))</span><br><span class="line">        self.panel = Panel(self)</span><br><span class="line">        self.Center()</span><br><span class="line">        self.image_cover = Image(<span class="string">&#x27;camera.jpeg&#x27;</span>, BITMAP_TYPE_ANY).Scale(<span class="number">350</span>, <span class="number">300</span>)</span><br><span class="line">        self.bmp = StaticBitmap(self.panel, -<span class="number">1</span>, Bitmap(self.image_cover))</span><br><span class="line">        self.counter = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">        start_button = Button(self.panel, label=<span class="string">&#x27;Start&#x27;</span>)</span><br><span class="line">        close_button = Button(self.panel, label=<span class="string">&#x27;Close&#x27;</span>)</span><br><span class="line">        take_button = Button(self.panel, label=<span class="string">&#x27;Take photo&#x27;</span>)</span><br><span class="line">        self.Bind(EVT_BUTTON, self.start, start_button)</span><br><span class="line">        self.Bind(EVT_BUTTON, self.close, close_button)</span><br><span class="line">        self.Bind(EVT_BUTTON, self.take, take_button)</span><br><span class="line"></span><br><span class="line">        self.grid_bag_sizer = GridBagSizer(hgap=<span class="number">5</span>, vgap=<span class="number">5</span>)</span><br><span class="line">        self.grid_bag_sizer.Add(self.bmp, pos=(<span class="number">0</span>, <span class="number">0</span>), flag=ALL | EXPAND, span=(<span class="number">4</span>, <span class="number">4</span>), border=<span class="number">5</span>)</span><br><span class="line">        self.grid_bag_sizer.Add(start_button, pos=(<span class="number">4</span>, <span class="number">1</span>), flag=ALL | ALIGN_CENTER_VERTICAL, span=(<span class="number">1</span>, <span class="number">1</span>), border=<span class="number">5</span>)</span><br><span class="line">        self.grid_bag_sizer.Add(close_button, pos=(<span class="number">4</span>, <span class="number">2</span>), flag=ALL | ALIGN_CENTER_VERTICAL, span=(<span class="number">1</span>, <span class="number">1</span>), border=<span class="number">5</span>)</span><br><span class="line">        self.grid_bag_sizer.Add(take_button, pos=(<span class="number">4</span>, <span class="number">3</span>), flag=ALL | ALIGN_CENTER_VERTICAL, span=(<span class="number">1</span>, <span class="number">1</span>), border=<span class="number">5</span>)</span><br><span class="line"></span><br><span class="line">        self.grid_bag_sizer.AddGrowableCol(<span class="number">0</span>, <span class="number">1</span>)</span><br><span class="line">        self.grid_bag_sizer.AddGrowableRow(<span class="number">0</span>, <span class="number">1</span>)</span><br><span class="line">        self.panel.SetSizer(self.grid_bag_sizer)</span><br><span class="line">        self.grid_bag_sizer.Fit(self)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># opencv 开启普通摄像头函数</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">open_camera</span>(<span class="params">self, event</span>):</span></span><br><span class="line">        self.cap = cv2.VideoCapture(<span class="number">0</span>)</span><br><span class="line">        <span class="keyword">while</span> self.cap.isOpened():</span><br><span class="line">            flag, im_rd = self.cap.read()</span><br><span class="line">            self.frame = im_rd</span><br><span class="line">            height, width = im_rd.shape[:<span class="number">2</span>]</span><br><span class="line">            image1 = cv2.cvtColor(im_rd, cv2.COLOR_BGR2RGB)</span><br><span class="line">            pic = Bitmap.FromBuffer(width, height, image1)</span><br><span class="line">            self.bmp.SetBitmap(pic)</span><br><span class="line">            self.grid_bag_sizer.Fit(self)</span><br><span class="line">        self.cap.release()</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 一般免驱摄像头截取函数</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">take</span>(<span class="params">self, event</span>):</span></span><br><span class="line">        cv2.imwrite(<span class="built_in">str</span>(self.counter) + <span class="string">&quot;.jpg&quot;</span>, self.frame)</span><br><span class="line">        self.counter += <span class="number">1</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">start</span>(<span class="params">self, event</span>):</span></span><br><span class="line">        <span class="comment"># self.open_camera(event)   # 这样不行的</span></span><br><span class="line">        <span class="keyword">import</span> _thread</span><br><span class="line">        _thread.start_new_thread(self.open_camera, (event,))</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">close</span>(<span class="params">self, event</span>):</span></span><br><span class="line">        self.cap.release()</span><br><span class="line">        self.bmp.SetBitmap(Bitmap(self.image_cover))</span><br><span class="line">        self.grid_bag_sizer.Fit(self)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">camera_app</span>(<span class="params">App</span>):</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">OnInit</span>(<span class="params">self</span>):</span></span><br><span class="line">        self.frame = camera(parent=<span class="literal">None</span>, title=<span class="string">&quot;camera&quot;</span>)</span><br><span class="line">        self.frame.Show(<span class="literal">True</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    app = camera_app()</span><br><span class="line">    app.MainLoop()</span><br></pre></td></tr></table></figure>
<p>​        点击start开始在框架内部显示视屏的时候，拖动一下这个框架，程序会卡死。因为我们的程序只有一个线程，这时程序正在while死循环里面进行视屏显示，占用了这唯一的一个线程，如果我们进行UI操作的话，程序就会被崩溃。</p>
<p>​        解决办法就是，创建一个新的线程，让按钮的动作函数在这个新的子线程中执行，主线程我们进行UI的操作，比如框架的拖动，放大缩小。</p>
<pre><code>     代码可以运行起来，唯一的问题是显示的摄像头视频会不停闪烁，后面博文中给出解决办法。</code></pre>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/17/LVGL%E5%BC%80%E5%85%B3%E9%83%A8%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/17/LVGL%E5%BC%80%E5%85%B3%E9%83%A8%E4%BB%B6/" class="post-title-link" itemprop="url">LVGL开关部件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-17 14:04:31" itemprop="dateCreated datePublished" datetime="2023-12-17T14:04:31+08:00">2023-12-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/17/LVGL%E5%BC%80%E5%85%B3%E9%83%A8%E4%BB%B6/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL开关部件" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/17/LVGL%E5%BC%80%E5%85%B3%E9%83%A8%E4%BB%B6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/17/LVGL%E5%BC%80%E5%85%B3%E9%83%A8%E4%BB%B6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px?p=29&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px?p=29&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171410010.png" style="zoom:70%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171414350.png"></p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171416390.png"></p>
<p>​        这个默认创建出来时候没有任何效果，点击之后也没有任何效果，如下图所示：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171417445.png"></p>
<p>​        这是为什么呢？？？要像下面这样修改：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171421540.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171424004.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/17/LVGL%E6%8C%89%E9%92%AE%E9%83%A8%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/17/LVGL%E6%8C%89%E9%92%AE%E9%83%A8%E4%BB%B6/" class="post-title-link" itemprop="url">LVGL按钮部件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-17 12:44:32" itemprop="dateCreated datePublished" datetime="2023-12-17T12:44:32+08:00">2023-12-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/17/LVGL%E6%8C%89%E9%92%AE%E9%83%A8%E4%BB%B6/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL按钮部件" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/17/LVGL%E6%8C%89%E9%92%AE%E9%83%A8%E4%BB%B6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/17/LVGL%E6%8C%89%E9%92%AE%E9%83%A8%E4%BB%B6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px?p=27&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px?p=27&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171246031.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171325057.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/17/LVGL%E6%A0%87%E7%AD%BE%E9%83%A8%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/17/LVGL%E6%A0%87%E7%AD%BE%E9%83%A8%E4%BB%B6/" class="post-title-link" itemprop="url">LVGL标签部件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-17 10:29:18" itemprop="dateCreated datePublished" datetime="2023-12-17T10:29:18+08:00">2023-12-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/17/LVGL%E6%A0%87%E7%AD%BE%E9%83%A8%E4%BB%B6/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL标签部件" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/17/LVGL%E6%A0%87%E7%AD%BE%E9%83%A8%E4%BB%B6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/17/LVGL%E6%A0%87%E7%AD%BE%E9%83%A8%E4%BB%B6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px?p=25&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px?p=25&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171030918.png" style="zoom:97%;"></p>
<h4 id="如何创建标签部件及设置文本"><a href="#如何创建标签部件及设置文本" class="headerlink" title="如何创建标签部件及设置文本"></a>如何创建标签部件及设置文本</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171033751.png" style="zoom:80%;">

<h4 id="如何改变文本的样式"><a href="#如何改变文本的样式" class="headerlink" title="如何改变文本的样式"></a>如何改变文本的样式</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171041929.png" style="zoom:80%;">

<h4 id="当文本长度超过部件大小时候怎么显示"><a href="#当文本长度超过部件大小时候怎么显示" class="headerlink" title="当文本长度超过部件大小时候怎么显示"></a>当文本长度超过部件大小时候怎么显示</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171112959.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/17/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%BA%8B%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/17/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%BA%8B%E4%BB%B6/" class="post-title-link" itemprop="url">LVGL基础对象样式和事件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-17 10:17:38" itemprop="dateCreated datePublished" datetime="2023-12-17T10:17:38+08:00">2023-12-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/17/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%BA%8B%E4%BB%B6/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL基础对象样式和事件" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/17/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%BA%8B%E4%BB%B6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/17/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E6%A0%B7%E5%BC%8F%E5%92%8C%E4%BA%8B%E4%BB%B6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px/?p=21&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px/?p=21&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<h3 id="样式"><a href="#样式" class="headerlink" title="样式"></a>样式</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312132218632.png" style="zoom:67%;">

<h4 id="如何给部件添加样式"><a href="#如何给部件添加样式" class="headerlink" title="如何给部件添加样式"></a>如何给部件添加样式</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312132226561.png" style="zoom:67%;">

<h4 id="什么时候样式生效"><a href="#什么时候样式生效" class="headerlink" title="什么时候样式生效"></a>什么时候样式生效</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312132232459.png" style="zoom:67%;">

<h4 id="有哪些样式属性可以设置"><a href="#有哪些样式属性可以设置" class="headerlink" title="有哪些样式属性可以设置"></a>有哪些样式属性可以设置</h4><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170943030.png"></p>
<p>比如边框设置：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170948507.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170948196.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170949924.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170949868.png" style="zoom:67%;">

<p>比如轮廓设置：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170951575.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170952022.png" style="zoom:67%;">

<h4 id="如何单独设置部件中某个部分的样式"><a href="#如何单独设置部件中某个部分的样式" class="headerlink" title="如何单独设置部件中某个部分的样式"></a>如何单独设置部件中某个部分的样式</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170955158.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170955497.png" style="zoom:57%;">

<p>​        如何知道一个部件有哪些部分组成？可以看官网资料：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312170957224.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171000873.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171001900.png" style="zoom:50%;">

<h3 id="事件"><a href="#事件" class="headerlink" title="事件"></a>事件</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171005398.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171006306.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171014234.png" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312171021179.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/14/ESP32%20K%20Type%20Thermocouple%20with%20MAX6675%20Amplifier/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/14/ESP32%20K%20Type%20Thermocouple%20with%20MAX6675%20Amplifier/" class="post-title-link" itemprop="url">ESP32 K Type Thermocouple with MAX6675 Amplifier</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-14 22:32:51" itemprop="dateCreated datePublished" datetime="2023-12-14T22:32:51+08:00">2023-12-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/14/ESP32%20K%20Type%20Thermocouple%20with%20MAX6675%20Amplifier/" class="post-meta-item leancloud_visitors" data-flag-title="ESP32 K Type Thermocouple with MAX6675 Amplifier" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/14/ESP32%20K%20Type%20Thermocouple%20with%20MAX6675%20Amplifier/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/14/ESP32%20K%20Type%20Thermocouple%20with%20MAX6675%20Amplifier/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         原文链接：<a target="_blank" rel="noopener" href="https://randomnerdtutorials.com/esp32-k-type-thermocouple-max6675/">https://randomnerdtutorials.com/esp32-k-type-thermocouple-max6675/</a></p>
<p>​         A K-type thermocouple is a type of temperature sensor with a wide measurement range like −200 to 1260ºC (−326 to 2300ºF).</p>
<p>​        Our tutorial is about the k-type thermocouple. A k-type thermocouple is made out of chrome and alumel conductors and has a general temperature range of −200 to 1260ºC (−328 to 2300ºF).</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142233267.png" style="zoom:50%;">

<h3 id="MAX6675-Amplifier"><a href="#MAX6675-Amplifier" class="headerlink" title="MAX6675 Amplifier"></a>MAX6675 Amplifier</h3><p>​        To get the temperature from the thermocouple we need a thermocouple amplifier. The temperature output from the thermocouple amplifier depends on the voltage read on the reference junction. The voltage at the reference junction depends on the temperature difference between the reference junction and the thermal junction. So, we need to know the temperature at the reference junction.</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142234660.png" style="zoom:50%;">

<p>​        The MAX6675 thermocouple comes with a temperature sensor to measure temperature at the reference junction (cold-compensation reference) and amplifies the tiny voltage at the reference junction so that we can read it using our microcontrollers. The MAX6675 amplifier communicates with a microcontroller using SPI communication protocol and the data is output in a 12-bit resolution.</p>
<h3 id="Schematic-–-ESP32-with-K-type-thermocouple-and-MAX6675-Amplifier"><a href="#Schematic-–-ESP32-with-K-type-thermocouple-and-MAX6675-Amplifier" class="headerlink" title="Schematic – ESP32 with K-type thermocouple and MAX6675 Amplifier"></a>Schematic – ESP32 with K-type thermocouple and MAX6675 Amplifier</h3><p>​        Wire the MAX6675 Amplifier to the ESP32 as shown in the following schematic diagram.</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142236994.png" style="zoom:67%;">

<p>​        You can also follow the next table.</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142236377.png" style="zoom:50%;">

<h3 id="Installing-MAX6675-Arduino-Library"><a href="#Installing-MAX6675-Arduino-Library" class="headerlink" title="Installing MAX6675 Arduino Library"></a>Installing MAX6675 Arduino Library</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142237084.png" style="zoom:67%;">

<h3 id="Code-–-Get-Temperature-from-K-Type-Thermocouple-with-MAX-6675-Amplifier"><a href="#Code-–-Get-Temperature-from-K-Type-Thermocouple-with-MAX-6675-Amplifier" class="headerlink" title="Code – Get Temperature from K-Type Thermocouple with MAX 6675 Amplifier"></a>Code – Get Temperature from K-Type Thermocouple with MAX 6675 Amplifier</h3><p>​        The code was adapted from the example provided by the library to make it compatible with the ESP32.</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// this example is public domain. enjoy! https://learn.adafruit.com/thermocouple/</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;max6675.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> thermoDO = <span class="number">19</span>;</span><br><span class="line"><span class="keyword">int</span> thermoCS = <span class="number">23</span>;</span><br><span class="line"><span class="keyword">int</span> thermoCLK = <span class="number">5</span>;</span><br><span class="line"></span><br><span class="line"><span class="function">MAX6675 <span class="title">thermocouple</span><span class="params">(thermoCLK, thermoCS, thermoDO)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">setup</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  Serial.begin(<span class="number">9600</span>);</span><br><span class="line"></span><br><span class="line">  Serial.println(<span class="string">&quot;MAX6675 test&quot;</span>);</span><br><span class="line">  <span class="comment">// wait for MAX chip to stabilize</span></span><br><span class="line">  delay(<span class="number">500</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">loop</span><span class="params">()</span> </span>&#123;</span><br><span class="line">  <span class="comment">// basic readout test, just print the current temp</span></span><br><span class="line">  </span><br><span class="line">  Serial.print(<span class="string">&quot;C = &quot;</span>); </span><br><span class="line">  Serial.println(thermocouple.readCelsius());</span><br><span class="line">  Serial.print(<span class="string">&quot;F = &quot;</span>);</span><br><span class="line">  Serial.println(thermocouple.readFahrenheit());</span><br><span class="line">  </span><br><span class="line">  <span class="comment">// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!</span></span><br><span class="line">  delay(<span class="number">1000</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>但是网友也有下面的反馈：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312142243376.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/12/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E5%A4%A7%E5%B0%8F%E4%BD%8D%E7%BD%AE%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/12/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E5%A4%A7%E5%B0%8F%E4%BD%8D%E7%BD%AE%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F/" class="post-title-link" itemprop="url">LVGL基础对象大小位置对齐方式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-12 21:14:23" itemprop="dateCreated datePublished" datetime="2023-12-12T21:14:23+08:00">2023-12-12</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/12/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E5%A4%A7%E5%B0%8F%E4%BD%8D%E7%BD%AE%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL基础对象大小位置对齐方式" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/12/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E5%A4%A7%E5%B0%8F%E4%BD%8D%E7%BD%AE%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/12/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E5%A4%A7%E5%B0%8F%E4%BD%8D%E7%BD%AE%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px/?p=18&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px/?p=18&amp;spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<h3 id="部件的基本属性"><a href="#部件的基本属性" class="headerlink" title="部件的基本属性"></a>部件的基本属性</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122119400.png" style="zoom:67%;">

<h4 id="大小"><a href="#大小" class="headerlink" title="大小"></a>大小</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122123156.png" style="zoom:50%;">

<h4 id="位置"><a href="#位置" class="headerlink" title="位置"></a>位置</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122128839.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122129380.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122136245.png" style="zoom:67%;">

<h4 id="对齐"><a href="#对齐" class="headerlink" title="对齐"></a>对齐</h4><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122140364.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122141211.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122144326.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122147603.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312122148108.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/10/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E7%AE%80%E4%BB%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/10/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E7%AE%80%E4%BB%8B/" class="post-title-link" itemprop="url">LVGL基础对象简介</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-10 21:19:22" itemprop="dateCreated datePublished" datetime="2023-12-10T21:19:22+08:00">2023-12-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/10/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E7%AE%80%E4%BB%8B/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL基础对象简介" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/10/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E7%AE%80%E4%BB%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/10/LVGL%E5%9F%BA%E7%A1%80%E5%AF%B9%E8%B1%A1%E7%AE%80%E4%BB%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px?p=16&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px?p=16&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        LVGL的编程思想是采用面向对象的方式，以抽象的类来实例化不同的对象（部件）。</p>
<p>​        C语言中没有“类”的概念，LVGL以结构体的形式来实现“类”的思维。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102144325.png" style="zoom:67%;">

<p>​        <strong>LVGL以活动屏幕作为父对象</strong>：lv_obj_t* switch_obj = lv_switch_create(lv_scr_act());</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102151814.png" style="zoom:87%;">

<p>​        这里为什么会重叠在一起，当以switch1为父对象创建switch2，switch2在switch1的左上角。</p>
<h3 id="基础对象简介"><a href="#基础对象简介" class="headerlink" title="基础对象简介"></a>基础对象简介</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102200845.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102205728.png" style="zoom:67%;">

<p>​        运行效果如下：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102205512.png"></p>
<p>​        可以看到这个基础部件就是一个矩形框，位于父对象的左上角。</p>
<h3 id="父和子对象的关系"><a href="#父和子对象的关系" class="headerlink" title="父和子对象的关系"></a>父和子对象的关系</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102208786.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/12/10/LVGL%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/12/10/LVGL%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">LVGL模拟器使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-12-10 19:59:12" itemprop="dateCreated datePublished" datetime="2023-12-10T19:59:12+08:00">2023-12-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/12/10/LVGL%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%BD%BF%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="LVGL模拟器使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/12/10/LVGL%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%BD%BF%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/12/10/LVGL%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1CG4y157Px?p=15&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1CG4y157Px?p=15&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        安装codeblock：codeblocks-20.03mingw-setup</p>
<p>​        LVGL的官网-&gt;github仓库，<a target="_blank" rel="noopener" href="https://lvgl.io/">https://lvgl.io</a> ,找到：<a target="_blank" rel="noopener" href="https://github.com/lvgl/lv_port_win_codeblocks">https://github.com/lvgl/lv_port_win_codeblocks</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102014400.png" style="zoom:50%;">

<p>直接download  ZIP。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102017471.png" style="zoom:50%;">

<p>这样下载的话，有弊端，这两个文件夹是空的，因为那两个文件夹是属于子模块的内容，要点进去这两个文件夹，然后再download zip，再把解压后的文件拷贝到第一步下载的空文件夹里面。</p>
<p>（a）配置屏幕分辨率，修改配置文件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102047102.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102049911.png" style="zoom:67%;">

<p>（b）建立专门存放lvgl用户代码的文件，移植和管理更加方便</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102054688.png" style="zoom:67%;">

<p>(c) 编写用户代码，在主函数中调用</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102105601.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102106355.png" style="zoom:67%;">

<p>效果如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202312102107177.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
